
var exec = require("child_process").exec;

//我们的处理程序函数需要接收response参数，为了对请求作出直接的响应。
function start(response){
	console.log("Request handler 'start' was called.");

	/*exec("ls -lah", function(error,stdout,stderr){
		response.writeHead(200,{"Content-Type":"text/plain"});
		response.write(stdout);
		response.end();
	});*/
	exec("find /",
	    { timeout: 10000, maxBuffer: 20000*1024 },
	    function (error, stdout, stderr) {
	      response.writeHead(200, {"Content-Type": "text/plain"});
	      response.write(stdout);
	      response.end();
    });
}
//start处理程序在exec()的匿名回调函数中做请求响应的操作，
//而upload处理程序仍然是简单的回复“Hello World”，只是这次是使用response对象而已。
function upload(response){
	console.log("Request handler 'upload' was called.");
	response.writeHead(200, {"Content-Type": "text/plain"});
	response.write("Hello Upload");
	response.end();
}

exports.start = start;
exports.upload = upload;